<?php
/**
 * Created by PhpStorm.
 * User: 陈森
 * Date: 2020/12/21
 * Time: 13:25
 */

namespace app\admin\model\member;


use core\basic\Model;

class BuyModel extends Model
{
//查询银行卡信息
    public function UserbankInfo($where)
    {

        return parent::table('ay_bank')->where($where)->find();
    }

    // 提交申请购买积分
    public function addBuy($data)
    {
        return parent::table('ay_buy')->insert($data);
    }
	// 查询会员购买积分
	public function BuyInfo($where)
	{
		return parent::table('ay_buy')->where($where)->find();
	}
	// 提交申请购买积分
	public function Buylist($start,$limit)
	{
		$field = array(
			'b.*',
			'a.username',
			'a.usermobile',
			'c.Card',
			'c.account_name',
			'c.Bank_deposit',
		);
		$join = array(
			'ay_member a',
			'b.user_id=a.id',
			'LEFT'
		);
		$joins=array(
			'ay_bank c',
			'b.bank_id=c.id',
		);
		return parent::table('ay_buy b')
			->field($field)
			->join($join)
			->join($joins)
			->limit($start,$limit)
			->order('add_time desc')
			->select();

	}
	// 修改状态
	public function BuysetField($where,$data)
	{
		return parent::table('ay_buy')->where($where)->update($data);
	}
	//查询当前会员申请的充值记录
	public function GetBuy($where)
	{
		return parent::table('ay_buy')->where($where)->order('add_time desc')->select();
	}
}